﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebTraderLiteCL;

namespace WebTraderLite.Account
{
    public partial class ChangeAccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            if (!Page.IsPostBack)
            {

                string user = System.Web.HttpContext.Current.User.Identity.Name.ToString();
                User curUser = new User(user);

                FirstName.Text = curUser.getFirstName();
                LastName.Text = curUser.getLastName();
                Address.Text = curUser.getUserAddress();
                Zip.Text = curUser.getzipCode();
                Email.Text =curUser.getEmail();
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string user = System.Web.HttpContext.Current.User.Identity.Name.ToString();
            GenUser curUser = new GenUser(user);

            string firstName = FirstName.Text;
            string lastName = LastName.Text; 
            string address = Address.Text;
            string zipcode = Zip.Text;
            string email = Email.Text;

            curUser.setFirstName(firstName);
            curUser.setLastName(lastName);
            curUser.setUserAddress(address);
            curUser.setzipCode(zipcode);
            curUser.setEmail(email);

            DBTransactions d = new DBTransactions();
            d.updateUser(curUser);
            Response.Redirect("~/Account/ChangeAccount.aspx");


        }//end btnChangeInformation_Click
    }
}